package com.wyix.entity;

import java.util.Date;

/**
 * @author wangdx
 * @since 2025/8/1
 */
public class SalesRecord {
    private static int nextId = 1; // 静态变量，用于自动生成销售ID
    private int recordId;
    private Car car; // 组合：销售记录包含一辆汽车
    private double salePrice;
    private Date saleDate;
    private String customerName;

    public SalesRecord(Car car, double salePrice, String customerName) {
        this.recordId = nextId++;
        this.car = car;
        this.salePrice = salePrice;
        this.saleDate = new Date(); // 当前日期
        this.customerName = customerName;
    }

    // 打印销售单
    public void printSalesReceipt() {
        System.out.println("\n===== 汽车销售单 =====");
        System.out.println("销售单号: " + recordId);
        System.out.println("销售日期: " + saleDate);
        System.out.println("客户姓名: " + customerName);
        System.out.println("汽车信息: " + car);
        System.out.println("销售价格: " + salePrice);
        System.out.println("======================");
    }

    // 静态方法：获取总销售记录数
    public static int getTotalSalesCount() {
        return nextId - 1;
    }
}
